CISC 1110 Lab 10

 

      Write a program that contrasts the action of a while loop and a do-while loop.

 

A. First, write a while loop that –one at a time--reads integer values and prints them. It reads each value into a variable called num, prints the value, the repeats the process as long as num is less than 50.

      Remember to use a structured read loop, reading the first value outside the loop and the remaining values inside the loop at the bottom.

 

a. Run the program and try entering this series of values: 4, 0, 57, 12.

What is printed by the program? Why did the loop stop?

 

 

 

b. Run the program again and try entering this series of values: 76, 3, -1.

                 What is printed by the program? Why did the loop stop?

 

 

 

B. Second, change the loop to a do-while loop, with the test at the bottom. Read and print each value inside the loop. 

 

a. Run the program and try entering this series of values: 4, 0, 57, 12.

What is printed by the program? Why did the loop stop?

 

 

 

b. Run the program again and try entering this series of values: 76, 3, -1.

                 What is printed by the program? Why did the loop stop?